package authorizedDao

import (
	"gitee.com/yangguoliang001/go-gin-vue3/BO"
	"gitee.com/yangguoliang001/go-gin-vue3/QO"
	"gitee.com/yangguoliang001/go-gin-vue3/model"
	"gitee.com/yangguoliang001/go-gin-vue3/vo"
	"gorm.io/gorm"
)

type AuthorizedDao interface {
	QueryAuthList(params QO.AuthorizedListReq) (authListRes vo.AuthorizedListVO, err error)
	AddAuthorized(authUser model.AuthorizedDO) (err error)
	UpdateAuthorized(authReq QO.UpdateAuthorizedReq) (err error)
	DeleteAuthorized(id int) (err error)

	QueryAuthApiDetail(apiReq QO.AddAuthApiReq) (apiItem model.AuthorizedApiDO, err error)
	QueryAuthApiList(businessKey string) (apiList []model.AuthorizedApiDO, err error)
	AddAuthorizedApi(apiReq model.AuthorizedApiDO) (apiItem model.AuthorizedApiDO, err error)
	DeleteAuthorizedApi(id string) (err error)
	QueryMethodList() (methodList []BO.MethodBO, err error)
}

type authorizedDao struct {
	db *gorm.DB
}

func New(db *gorm.DB) AuthorizedDao {
	return &authorizedDao{
		db: db,
	}
}
